package assemblers.beans;

import assemblers.interfaces.PhoneNumberAssembler;
import infos.PhoneNumberInfo;
import model.PhoneNumber;

import javax.ejb.Stateless;
import java.util.ArrayList;
import java.util.List;

@Stateless(name = "PhoneNumberAssembler")
public class PhoneNumberAssemblerBean implements PhoneNumberAssembler {

    @Override
    public PhoneNumber assemble(PhoneNumberInfo phoneNumberInfo) {
        PhoneNumber phoneNumber = new PhoneNumber();
        phoneNumber.setId(phoneNumberInfo.getId());
        phoneNumber.setCode(phoneNumberInfo.getCode());
        phoneNumber.setNumber(phoneNumberInfo.getNumber());
        return phoneNumber;
    }

    @Override
    public List<PhoneNumber> assembleList(List<PhoneNumberInfo> phoneNumberInfos) {
        List<PhoneNumber> phoneNumbers = new ArrayList<PhoneNumber>();
        for (PhoneNumberInfo phoneNumberInfo : phoneNumberInfos) {
            PhoneNumber phoneNumber = assemble(phoneNumberInfo);
            phoneNumbers.add(phoneNumber);
        }
        return phoneNumbers;
    }
}
